﻿using System;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Text;
using System.Windows.Forms;

namespace HslCommunication.Controls
{
	/// <summary>
	/// 一个罐子形状的控件
	/// </summary>
	// Token: 0x02000174 RID: 372
	[DefaultBindingProperty("Text")]
	[DefaultProperty("Text")]
	public class UserDrum : UserControl
	{
		/// <summary>
		/// 实例化一个罐子形状的控件
		/// </summary>
		// Token: 0x06001EB3 RID: 7859 RVA: 0x0009400C File Offset: 0x0009220C
		public UserDrum()
		{
			this.DoubleBuffered = true;
			this.stringFormat.Alignment = StringAlignment.Center;
			this.stringFormat.LineAlignment = StringAlignment.Center;
			this.InitializeComponent();
		}

		/// <summary>
		/// 获取或设置容器罐的背景色。
		/// </summary>
		// Token: 0x17000650 RID: 1616
		// (get) Token: 0x06001EB4 RID: 7860 RVA: 0x000940D4 File Offset: 0x000922D4
		// (set) Token: 0x06001EB5 RID: 7861 RVA: 0x000940EC File Offset: 0x000922EC
		[Browsable(true)]
		[DefaultValue(typeof(Color), "Silver")]
		[Category("外观")]
		[Description("获取或设置容器罐的背景色。")]
		public Color DrumBackColor
		{
			get
			{
				return this.backColor;
			}
			set
			{
				this.backColor = value;
				this.backBrush.Dispose();
				this.backBrush = new SolidBrush(value);
				base.Invalidate();
			}
		}

		/// <summary>
		/// 获取或设置容器罐的边框色。
		/// </summary>
		// Token: 0x17000651 RID: 1617
		// (get) Token: 0x06001EB6 RID: 7862 RVA: 0x00094118 File Offset: 0x00092318
		// (set) Token: 0x06001EB7 RID: 7863 RVA: 0x00094130 File Offset: 0x00092330
		[Browsable(true)]
		[DefaultValue(typeof(Color), "DimGray")]
		[Category("外观")]
		[Description("获取或设置容器罐的边框色。")]
		public Color BorderColor
		{
			get
			{
				return this.borderColor;
			}
			set
			{
				this.borderColor = value;
				this.borderPen.Dispose();
				this.borderPen = new Pen(value);
				base.Invalidate();
			}
		}

		/// <summary>
		/// 获取或设置显示的文本信息
		/// </summary>
		// Token: 0x17000652 RID: 1618
		// (get) Token: 0x06001EB8 RID: 7864 RVA: 0x0009415C File Offset: 0x0009235C
		// (set) Token: 0x06001EB9 RID: 7865 RVA: 0x00094174 File Offset: 0x00092374
		[Browsable(true)]
		[Category("外观")]
		[EditorBrowsable(EditorBrowsableState.Always)]
		[Bindable(true)]
		[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
		[Description("获取或设置在容器上显示的文本")]
		public override string Text
		{
			get
			{
				return this.text;
			}
			set
			{
				this.text = value;
				base.Invalidate();
			}
		}

		/// <summary>
		/// 获取或设置文本的颜色
		/// </summary>
		// Token: 0x17000653 RID: 1619
		// (get) Token: 0x06001EBA RID: 7866 RVA: 0x00094185 File Offset: 0x00092385
		// (set) Token: 0x06001EBB RID: 7867 RVA: 0x0009418D File Offset: 0x0009238D
		[Browsable(true)]
		[Category("外观")]
		[DefaultValue(typeof(Color), "White")]
		[Description("获取或设置文本的颜色")]
		public override Color ForeColor
		{
			get
			{
				return this.textColor;
			}
			set
			{
				this.textColor = value;
				this.textBrush.Dispose();
				this.textBrush = new SolidBrush(value);
				base.Invalidate();
			}
		}

		/// <summary>
		/// 获取或设置文本的背景色
		/// </summary>
		// Token: 0x17000654 RID: 1620
		// (get) Token: 0x06001EBC RID: 7868 RVA: 0x000941B6 File Offset: 0x000923B6
		// (set) Token: 0x06001EBD RID: 7869 RVA: 0x000941BE File Offset: 0x000923BE
		[Browsable(true)]
		[Category("外观")]
		[DefaultValue(typeof(Color), "DarkGreen")]
		[Description("获取或设置文本的背景色")]
		public Color TextBackColor
		{
			get
			{
				return this.textBackColor;
			}
			set
			{
				this.textBackColor = value;
				this.textBackBrush.Dispose();
				this.textBackBrush = new SolidBrush(value);
				base.Invalidate();
			}
		}

		// Token: 0x06001EBE RID: 7870 RVA: 0x000941E8 File Offset: 0x000923E8
		private void UserDrum_Paint(object sender, PaintEventArgs e)
		{
			bool flag = !Authorization.nzugaydgwadawdibbas();
			if (!flag)
			{
				bool flag2 = base.Width < 40 || base.Height < 50;
				if (!flag2)
				{
					Graphics graphics = e.Graphics;
					graphics.SmoothingMode = SmoothingMode.HighQuality;
					graphics.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
					Point[] points = new Point[]
					{
						new Point(base.Width / 2, 20),
						new Point(base.Width - 10, base.Height * 3 / 10),
						new Point(base.Width - 10, base.Height * 7 / 10),
						new Point(base.Width / 2, base.Height - 20),
						new Point(10, base.Height * 7 / 10),
						new Point(10, base.Height * 3 / 10),
						new Point(base.Width / 2, 20)
					};
					graphics.FillPolygon(this.backBrush, points);
					graphics.DrawLines(this.borderPen, points);
					graphics.DrawCurve(this.borderPen, new Point[]
					{
						new Point(10, base.Height * 3 / 10),
						new Point(base.Width / 2, base.Height * 3 / 10 + base.Height / 25),
						new Point(base.Width - 10, base.Height * 3 / 10)
					});
					graphics.DrawCurve(this.borderPen, new Point[]
					{
						new Point(10, base.Height * 7 / 10),
						new Point(base.Width / 2, base.Height * 7 / 10 + base.Height / 25),
						new Point(base.Width - 10, base.Height * 7 / 10)
					});
					bool flag3 = !string.IsNullOrEmpty(this.text);
					if (flag3)
					{
						SizeF sizeF = graphics.MeasureString(this.text, this.Font, (base.Width - 20) * 3 / 5);
						bool flag4 = sizeF.Width < (float)((base.Width - 20) * 4 / 5);
						if (flag4)
						{
							sizeF.Width = (float)((base.Width - 20) * 3 / 5);
						}
						sizeF.Width += 10f;
						sizeF.Height += 5f;
						Rectangle rectangle = new Rectangle(base.Width / 2 - (int)(sizeF.Width / 2f), base.Height / 2 - (int)(sizeF.Height / 2f), (int)sizeF.Width, (int)sizeF.Height);
						graphics.FillRectangle(Brushes.DarkGreen, rectangle);
						graphics.DrawString(this.text, this.Font, this.textBrush, rectangle, this.stringFormat);
					}
				}
			}
		}

		/// <summary> 
		/// 清理所有正在使用的资源。
		/// </summary>
		/// <param name="disposing">如果应释放托管资源，为 true；否则为 false。</param>
		// Token: 0x06001EBF RID: 7871 RVA: 0x00094514 File Offset: 0x00092714
		protected override void Dispose(bool disposing)
		{
			bool flag = disposing && this.components != null;
			if (flag)
			{
				this.components.Dispose();
			}
			base.Dispose(disposing);
		}

		/// <summary> 
		/// 设计器支持所需的方法 - 不要修改
		/// 使用代码编辑器修改此方法的内容。
		/// </summary>
		// Token: 0x06001EC0 RID: 7872 RVA: 0x0009454C File Offset: 0x0009274C
		private void InitializeComponent()
		{
			base.SuspendLayout();
			base.AutoScaleDimensions = new SizeF(7f, 17f);
			base.AutoScaleMode = AutoScaleMode.Font;
			this.BackColor = Color.Transparent;
			this.Font = new Font("微软雅黑", 9f, FontStyle.Regular, GraphicsUnit.Point, 134);
			base.Margin = new Padding(3, 4, 3, 4);
			base.Name = "UserDrum";
			base.Size = new Size(166, 196);
			base.Paint += this.UserDrum_Paint;
			base.ResumeLayout(false);
		}

		// Token: 0x040006DE RID: 1758
		private Color backColor = Color.Silver;

		// Token: 0x040006DF RID: 1759
		private Brush backBrush = new SolidBrush(Color.Silver);

		// Token: 0x040006E0 RID: 1760
		private Color borderColor = Color.DimGray;

		// Token: 0x040006E1 RID: 1761
		private Pen borderPen = new Pen(Color.DimGray);

		// Token: 0x040006E2 RID: 1762
		private Color textColor = Color.White;

		// Token: 0x040006E3 RID: 1763
		private Brush textBrush = new SolidBrush(Color.White);

		// Token: 0x040006E4 RID: 1764
		private Color textBackColor = Color.DarkGreen;

		// Token: 0x040006E5 RID: 1765
		private Brush textBackBrush = new SolidBrush(Color.DarkGreen);

		// Token: 0x040006E6 RID: 1766
		private string text = string.Empty;

		// Token: 0x040006E7 RID: 1767
		private StringFormat stringFormat = new StringFormat();

		/// <summary> 
		/// 必需的设计器变量。
		/// </summary>
		// Token: 0x040006E8 RID: 1768
		private IContainer components = null;
	}
}
